/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ejbs;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.ejb.Singleton;

/**
 *
 * @author vasi
 */
@Singleton
public class MessageQueue implements MessageQueueLocal {
    
    private List<String> statusMessages = new LinkedList<String>();

    public void addStatusMessage(String message) {
        this.statusMessages.add(message);
    }

    public List<String> getStatusMessages(boolean flush) {
        if (flush){
            List<String> messages = new LinkedList<String>();
            Iterator<String> it = this.statusMessages.iterator();
            while (it.hasNext()){
                messages.add(new String(it.next()));
            }
            this.statusMessages.clear();
            return messages;
        } else {
            return this.statusMessages;
        }
    }
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
 
}
